<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%@ include file="/common/grid/jqGrid.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="">
	<meta http-equiv="description" content="">
	
  </head>
  
  <body>
    	<s:form name="frm" id="frm" method="post" action="" namespace="">
    		<s:hidden id="moduleId" name="lvvo.moduleId"></s:hidden>
    		
			<table cellspacing="0" width="100%">
				<tr>
					<td align="left">
    					<input type="button" value="新增" class="btn" onclick="addListDefine()" />
    				</td>
    			</tr>
    		</table>
    		
    		<table id="listGrid" cellpadding="3" cellspacing="0"></table>
			<div id="pager" style="text-align:center;"></div>
    	</s:form>
    
    <script type="text/javascript">
    $(document).ready(function(){
        var cName = new Array('列表编码', '列表名称', '每页条数', '操作');
    	var cModel = [
    					{name:'listCode', index:'listCode', width:'25%', align:'center', formatter:codeOption},
    					{name:'listName', index:'listName', width:'30%', align:'center'},
                        {name:'pageSize', index:'pageSize', width:'25%', align:'center'},
                        {name:'id', index:'id', width:'20%', align:'center', sortable:false, formatter:option}
                      ];
        var moduleId = $('#moduleId');
        newJqGrid({
        	id: 'id',
        	gridId: 'listGrid',
        	pagerId: 'pager',
        	url: 'inner/core/listDefineManageList.action?lvvo.moduleId=' + moduleId.val(),
        	head: cName,
        	column: cModel,
        	width: getBodyWidth(),
        	height: 'auto',
        	hasCb: false,
        	title: '列表定义列表'
        });
        
        $(window).resize(function(){
        	gridAutoWidth('listGrid', 'win');
        });
    });
    
    function codeOption(cellVal, options, row)
    {
        var realCode = row['listCode'];
        var index = realCode.lastIndexOf('_');
    	return realCode.substring(index + 1, realCode.length);
    }
    
    function option(cellVal, options, row)
    {
    	var html = '<a style="color:blue; text-decoration:underline" href="javascript:updateListDefine(\'' + row['id'] + '\')" >修改</a>';
    	html += ' <a style="color:blue; text-decoration:underline" href="javascript:delListDefine(\'' + row['id'] + '\')" >删除</a>';
    	return html;
    }
    
    function updateListDefine(id)
    {
    	var url = realPath + '/inner/core/toSaveListDefine.action?ld.id=' + id;
    	window.location.href = url;
    }
    
    function searchThis()
    {
    	toSearchList('listGrid', null);
    }

    function addListDefine()
    {
        var moduleId = $('#moduleId');
        var url = realPath + '/inner/core/toSaveListDefine.action?ld.listModule.id=' + moduleId.val();
        window.location.href = url;
    }

    function delListDefine(id)
    {
    	showConfirm('确认删除？', function(v){
        	if(v == true)
        	{
        		var url = 'inner/core/delListDefine.action?ld.id=' + id;
        		ajaxAction(url, 'get', 'frm', false, function(){
		    		searchThis();
		    	});
        	}
    	});
    }

    function returnBack()
    {
		var url = realPath + '/inner/core/listModuleManage.action';
		window.location.href = url;
    }
    </script>
  </body>
</html>
